package com.by.common.util;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;


public class DateFormatConverter extends JsonSerializer<Date>{
	//private SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
	/**
	 * change
	 * @param value 
	 * @param gen 
	 */
	@Override
	public void serialize(Date value, 
			JsonGenerator gen,
			SerializerProvider serializers)
			throws IOException, 
			JsonProcessingException {
		//1.change
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
		String dateStr=sdf.format(value);
		//2.json
		gen.writeString(dateStr);
	}
}
